package cn.edu.nuc.film.dto;

import java.util.List;

/**
 * 将获取的信息进行设置分页
 * @author win7
 *
 */
public class PageInfo {
	/**
	 * 当前页
	 */
	private int current = 1;
	/**
	 * 总记录数
	 */
	private int count;
	/**
	 *  一页多少条（每页记录数）
	 */
	private int offset = 5;
	/**
	 *  总页数
	 */
	private int total;
	/**
	 *  获取当前页的第一个数据的索引
	 */
	private int start;
	
	/**
	 * 获取的所有数据
	 */
	private List<?> list;
	
	
	public PageInfo() {
		super();
	}
	/**
	 * 构造一个带参的构造函数，通过传一个当前页来获取 ？???
	 * @param current
	 */
	public PageInfo(int current) {
		
		this.current = current;
	}
	public int getCurrent() {
		return current;
	}
	public void setCurrent(int current) {
		this.current = current;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
		this.setTotal(
				this.count/this.offset + ((this.count % this.offset) > 0 ? 1:0)
				);
		
	}
	public int getOffset() {
		return offset;
	}
	public void setOffset(int offset) {
		this.offset = offset;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public int getStart() {
		
		this.start = (this.current - 1) * this.offset;
		return start;
	}
	public List<?> getList() {
		return list;
	}
	public void setList(List<?> list) {
		this.list = list;
	}
	public void setStart(int start) {
		this.start = start;
	}
	@Override
	public String toString() {
		return "PageInfo [current=" + current + ", count=" + count + ", offset=" + offset + ", total=" + total
				+ ", start=" + start + ", list=" + list + "]";
	}
	
		
}
